<template>
    <div>
        <h1>分类展示</h1>
        <el-table :data="cate_list" style='width:60%'>
          <el-table-column label="分类名" prop="name"></el-table-column>
          <el-table-column label="图片">
              <template slot-scope="scope">
                  <img :src="'http://127.0.0.1:8000'+scope.row.img" >
              </template>
          </el-table-column>
          <el-table-column >
              <template slot-scope="scope">
                  <el-button >编辑</el-button>
                  <el-button type="danger" @click="del(scope.row.cate_id)">删除</el-button>
              </template>
          </el-table-column>
        </el-table>
    </div>
</template>

<script>
import axios from 'axios'
export default {
    data() {
        return {
            cate_list:[],
        }
    },
    methods: {
        del(cate_id){
            axios.delete('http://127.0.0.1:8000/cate/'+id+'/')
            .then(resp=>{
                alert('删除成功')
                this.created()
            })
        }
    },
    created() {
        axios.get('http://127.0.0.1:8000/cate/')
        .then(resp=>{
            this.cate_list=resp.data
        }).catch(error=>{
            console.log(error)
        })
    }
}
</script>

<style scoped>

</style>
